home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-22 | 2.2 KB | 116 lines | [TEXT/BROW] |
- // SoundSource.h
- // Created by Bill Hubauer on Fri, Jun 16, 1995 @ 7:33 AM.
-
- #ifndef __SoundSource__
- #define __SoundSource__
-
- #ifndef __MessageObjects__
- #include "MessageObjects.h"
- #endif
-
- #ifndef __SOUND__
- #include <sound.h>
- #endif
-
- #ifndef _OBJECTREF_
- #include "ObjectRef.h"
- #endif
-
- #ifndef __SSTYPES__
- #include "SSTypes.h"
- #endif
-
- #define msgSSReadComplete 3000
-
- class SSoundSource : public MMessageSender
- {
- public:
- SSoundSource(UInt32 bufferSize);
- virtual ~SSoundSource();
- enum{errBufferNotReady = 1,errBufferBusy = 2};
-
-
- virtual OSErr GetSHeader(SHeader*& header) = 0;
- UInt32 GetBufferSize() {return _bufferSize;}
-
- void SetAutoRefillQ(Boolean autoRefill) {_autoRefillQ = autoRefill;}
-
- virtual OSErr Initialize();
-
- // this function will start an async buffer
- virtual OSErr StartRead();
- OSErr GetBuffer(Ptr putItHere,UInt32& theSize);
-
- virtual void Reset() {}
-
- protected:
- void SendReadCompletion(UInt32 bytesRead,OSErr err) {_bufferReadyQ = true;_sizeInBuffer = bytesRead;BroadcastMessage(msgSSReadComplete,&err);}
- virtual void DoReadBuffer() = 0; // this function fills the buffer can calls SendReadCompletion
-
-
- Ptr _buffer;
- UInt32 _bufferSize;
- UInt32 _sizeInBuffer;
- Boolean _autoRefillQ;
-
- Boolean _bufferReadyQ;
-
- };
-
-
- class CSoundInputDevice;
-
- class SInputSource : public SSoundSource
- {
- public:
- SInputSource(UInt32 bufferSize,OSType quality);
- virtual ~SInputSource();
-
-
- virtual OSErr Initialize();
- virtual OSErr GetSHeader(SHeader*& header);
-
- protected:
- virtual void DoReadBuffer();
- static pascal void _CompleteProc(OSErr ioResult,UInt32 count,void* userData);
-
- private:
-
- CSoundInputDevice* _device;
- OSType _quality;
-
- SHeader _curHeader;
-
-
- };
-
-
- DEFINE_REF(SSoundSource)
-
-
- class ResSoundSource : public SSoundSource
- {
- public:
- ResSoundSource(UInt32 bufferSize,Handle lockedSndResource);
- virtual ~ResSoundSource();
-
- virtual OSErr Initialize();
- virtual OSErr GetSHeader(SHeader*& header);
-
- virtual void Reset() {_pos = _startPos;_bytesToGo = _length;_bufferReadyQ = true;}
-
- protected:
-
- virtual void DoReadBuffer();
-
- Handle _sndResource;
- UInt32 _length;
- UInt32 _bytesToGo;
- Ptr _startPos;
- Ptr _pos;
-
- };
-
-
- #endif
-